package cn.java71.servlet;

import cn.java71.entity.Student;
import cn.java71.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "showStudentServlet",value = "/showStudentServlet")
public class ShowStudentServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
    StudentService studentService =new StudentService();
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        long stuno=Long.parseLong(request.getParameter("stuno"));
        Student student=studentService.get(stuno);

        request.setAttribute("stu",student);

        request.getRequestDispatcher("/WEB-INF/views/studentshow.jsp").forward(request,response);

    }
}
